package cn.dq.demo.design.singleton;

import org.springframework.stereotype.Component;

@Component
//饿汉式单例：饿汉式在类创建的同时就已经创建好一个静态的对象供系统使用，以后不再改变，所以天生是线程安全的
public class HungrySingletonDesign {

    private static HungrySingletonDesign hungrySingletonDesign = new HungrySingletonDesign();

    private HungrySingletonDesign() {
    }


    public static HungrySingletonDesign getInstance() {
        return hungrySingletonDesign;
    }
}
